#pragma once
#include "CCSprite.h"

#include "cocos2d.h"
#include "CCLuaEngine.h"
#include "network/HttpClient.h"
#include "network/HttpRequest.h"
#include "network/HttpResponse.h"

USING_NS_CC;

class HttpSprite :
	public cocos2d::Sprite
{
public:
	HttpSprite();
	~HttpSprite();

	static HttpSprite* createWithCB(std::string url, std::function<void(int, cocos2d::Image*)> callBackFunc);
	static HttpSprite* createWithLuaCB(std::string url, cocos2d::LUA_FUNCTION lunCallBack);

	static void GetHttpImg(Ref* obj, std::string imgurl, int number);
	void onHttpRequestRptImg(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response);

private:
	cocos2d::LUA_FUNCTION _luaCallBackHandle = 0;
	std::function<void(int ,cocos2d::Image*)> _callBackHandle = nullptr;
};

